using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class LearnLogInfo
    {
		#region Local Variable
		public enum Field
		{
			ID,
			UserID,
			ItemID,
			LearnTime,
			Description
		}
		private Int64 _ID;
		private Int64 _UserID;
		private Int32 _ItemID;
		private DateTime _LearnTime;
		private String _Description;
		
		public Int64 ID{	get{ return _ID;} set{_ID = value;} }
		public Int64 UserID{	get{ return _UserID;} set{_UserID = value;} }
		public Int32 ItemID{	get{ return _ItemID;} set{_ItemID = value;} }
		public DateTime LearnTime{	get{ return _LearnTime;} set{_LearnTime = value;} }
		public String Description{	get{ return _Description;} set{_Description = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public LearnLogInfo()
		{
			_ID = 0;
			_UserID = 0;
			_ItemID = 0;
			_LearnTime = DateTime.Now;
			_Description = "";
		}
		public LearnLogInfo(
		Int64 ID,
		Int64 UserID,
		Int32 ItemID,
		DateTime LearnTime,
		String Description
		)
		{
			_ID = ID;
			_UserID = UserID;
			_ItemID = ItemID;
			_LearnTime = LearnTime;
			_Description = Description;
		}
		public LearnLogInfo(DataRow dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.ID.ToString()]);
				_UserID = dr[Field.UserID.ToString()] == DBNull.Value?0:Convert.ToInt64(dr[Field.UserID.ToString()]);
				_ItemID = dr[Field.ItemID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.ItemID.ToString()]);
				_LearnTime = dr[Field.LearnTime.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.LearnTime.ToString()]);
				_Description = dr[Field.Description.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Description.ToString()]);
			}
		}
		public LearnLogInfo(LearnLogInfo objEntr)
		{			
			_ID = objEntr.ID;			
			_UserID = objEntr.UserID;			
			_ItemID = objEntr.ItemID;			
			_LearnTime = objEntr.LearnTime;			
			_Description = objEntr.Description;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("LearnLog");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.ID.ToString(), typeof(Int64)),
				new DataColumn(Field.UserID.ToString(), typeof(Int64)),
				new DataColumn(Field.ItemID.ToString(), typeof(Int32)),
				new DataColumn(Field.LearnTime.ToString(), typeof(DateTime)),
				new DataColumn(Field.Description.ToString(), typeof(String))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.ID.ToString()] = _ID;
			row[Field.UserID.ToString()] = _UserID;
			row[Field.ItemID.ToString()] = _ItemID;
			row[Field.LearnTime.ToString()] = _LearnTime;
			row[Field.Description.ToString()] = _Description;
			return row;
		}
        #endregion InitTable
    }
}
